﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SQLServerDAL;


public class CardListDAL
{
    private int id = 0;

    public int Id
    {
        get { return id; }
        set { id = value; }
    }
    private String num = "";

    public String Num
    {
        get { return num; }
        set { num = value; }
    }
    private DateTime createDate = new DateTime();

    public DateTime CreateDate
    {
        get { return createDate; }
        set { createDate = value; }
    }
    private int typeID = 0;

    public int TypeID
    {
        get { return typeID; }
        set { typeID = value; }
    }
    private bool used = false;

    public bool Used
    {
        get { return used; }
        set { used = value; }
    }

    public CardListDAL(int cardListID, String cardListNum, DateTime createDate, int typeID, bool used)
    {
        this.id = cardListID;
        this.num = cardListNum;
        this.createDate = createDate;
        this.typeID = typeID;
        this.used = used;
    }
    /*
    public CardListDAL getCardListByType()
    {
        SQLServerDAL a = 
        return new CardListDAL();
    }*/
    public bool IsExist(int cardList_id)
    {
        bool exist = false;

        SQLServerDAL.SQLServerDAL dc = new SQLServerDAL.SQLServerDAL();

        dc.CommandText = "SELECT * FROM CardList_Tab WHERE cardList_id = @cardList_id";
        dc.AddParameter("@cardList_id", cardList_id);
        dc.ExecuteReader();
        if (dc.Reader.Read())
        {
            exist = true;
        }
        else
        {
            exist = false;
        }

        dc.CommandText = "SELECT * FROM CardList_Tab WHERE cardList_id = @cardList_id";
        dc.AddParameter("@cardList_id", cardList_id);
        dc.ExecuteReader();
        if (dc.Reader.Read())
        {
            exist = true;
        }
        else
        {
            exist = false;
        }

        dc.CloseReader();
        dc.CloseConntion();


        return exist;
    }
}
